package com.tianyang.yukuaifuzs.business.trade.view;

import android.annotation.SuppressLint;
import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.TextView;

import com.tianyang.yukuaifuzs.R;
import com.tianyang.yukuaifuzs.base.BaseTitleActivity;
import com.tianyang.yukuaifuzs.business.trade.bean.TradeRecordOutput;
import com.tianyang.yukuaifuzs.business.trade.contract.TradeConfig;
import com.tianyang.yukuaifuzs.utils.DateUtils;
import com.tianyang.yukuaifuzs.utils.VerifyUtil;

import butterknife.BindView;

/**
 * Description：交易详情
 * Created by xyj on 2024/3/18
 */
public class TradeDetailActivity extends BaseTitleActivity {

    @BindView(R.id.payTypeIv)
    ImageView payTypeIv;
    @BindView(R.id.amountTv)
    TextView amountTv;
    @BindView(R.id.createTimeTv)
    TextView createTimeTv;
    @BindView(R.id.posNumberTv)
    TextView posNumberTv;
    @BindView(R.id.feeTv)
    TextView feeTv;
    @BindView(R.id.bankNameTv)
    TextView bankNameTv;
    @BindView(R.id.showUserOrderIdTv)
    TextView showUserOrderIdTv;
    @BindView(R.id.userPayOrderStatusTv)
    TextView userPayOrderStatusTv;
    @BindView(R.id.paymentInstructionsTv)
    TextView paymentInstructionsTv;
    @BindView(R.id.payUserOrderOperaStatusTv)
    TextView payUserOrderOperaStatusTv;

    @Override
    protected int getLayoutResID() {
        return R.layout.activity_trade_detail;
    }

    @SuppressLint("SetTextI18n")
    @Override
    protected void initView() {
        super.initView();
        TradeRecordOutput output = (TradeRecordOutput) getIntent().getSerializableExtra(TradeConfig.INTENT_TRADE_OUTPUT);
        String title = getIntent().getStringExtra(TradeConfig.INTENT_TITLE);
        if (!TextUtils.isEmpty(title))
            commonTitle.setTitle(title);
        if (output != null) {
            amountTv.setText(VerifyUtil.decimalFormat(output.getAmount()));
            posNumberTv.setText(VerifyUtil.checkString(output.getPosNumber()));
            if (!TextUtils.isEmpty(output.getFee()))
                feeTv.setText(VerifyUtil.decimalFormat(output.getFee()));
            bankNameTv.setText(VerifyUtil.checkString(output.getBankName()));
            showUserOrderIdTv.setText(VerifyUtil.checkString(output.getShowUserOrderId()));
            if (!TextUtils.isEmpty(output.getPaymentInstructions()))
                paymentInstructionsTv.setText(output.getPaymentInstructions());
            if (output.getPayType() == 2) {
                payTypeIv.setImageResource(R.drawable.ic_pay_wx);
            } else if (output.getPayType() == 3) {
                payTypeIv.setImageResource(R.drawable.ic_pay_ali);
            } else if (output.getPayType() == 1) {
                payTypeIv.setImageResource(R.drawable.ic_pay_syx);
            } else {
                payTypeIv.setImageResource(R.drawable.ic_pay_union);
            }
            if (output.getCreateTime() > 0) {
                createTimeTv.setText(DateUtils.formatTime(output.getCreateTime()));
            } else {
                createTimeTv.setText(DateUtils.getCurrentTime("yyyy-MM-dd"));
            }
            switch (output.getUserPayOrderStatus()) {
                case 0:
                    userPayOrderStatusTv.setText("交易成功");
                    break;
                case 1:
                    userPayOrderStatusTv.setText("交易失败");
                    break;
                case 2:
                    userPayOrderStatusTv.setText("未支付");
                    break;
                case 3:
                    userPayOrderStatusTv.setText("交易中");
                    break;
                case 4:
                    userPayOrderStatusTv.setText("退款中");
                    break;
                case 5:
                    userPayOrderStatusTv.setText("退款成功");
                    break;
                case 6:
                    userPayOrderStatusTv.setText("退款失败");
                    break;
            }
            switch (output.getPayUserOrderOperaStatus()) {
                case 8:
                    payUserOrderOperaStatusTv.setText("延迟结算中");
                    break;
                case 3:
                    payUserOrderOperaStatusTv.setText("结算中");
                    break;
                case 2:
                    payUserOrderOperaStatusTv.setText("未结算");
                    break;
                case 1:
                    payUserOrderOperaStatusTv.setText("结算失败");
                    break;
                case 0:
                    payUserOrderOperaStatusTv.setText("结算成功");
                    break;
            }
        }
    }

    @Override
    protected boolean hasBindEventBus() {
        return false;
    }
}
